﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Styx;
using Styx.Helpers;
using Styx.Logic.BehaviorTree;
using Styx.Plugins.PluginClass;
using Styx.WoWInternals.WoWObjects;


using Styx.WoWInternals;


namespace PlaySafe
{
    public class PlaySafe : HBPlugin
    {
        public override string Name { get { return "Play Safe"; } }
        public override string Author { get { return "SwInY"; } }
        public override Version Version { get { return new Version(1, 0); } }

        public override void Pulse()
        {
            while (PlayerCount >= 1 && !StyxWoW.Me.IsActuallyInCombat && StyxWoW.Me.IsValid) 
            {
                // Anti AFK
                if (StyxWoW.Me.IsAFKFlagged)
                {
                    WoWMovement.Move(WoWMovement.MovementDirection.Forward, new TimeSpan(0, 0, 5));
                }
            }
        }

        public int PlayerCount
        {
            get
            {
                return ObjectManager.GetObjectsOfType<WoWPlayer>().Where(e => e.Distance < 50 && e.IsMoving && e.IsFlying).Count();
            }
        }
    }
}
